/**
 ******************************************************************************
 * @file           : main.c
 * @brief          : ADC Multi-Channel Sampling Example
 ******************************************************************************
 */

#include "stm32f4xx.h"
#include "./BSP/ADC/bsp_adc.h"
#include "./BSP/USART/bsp_usart.h"
#include <stdio.h>

int main(void)
{
    HAL_Init();
    SystemClock_Config();

    usart_init(115200);

    uint32_t channels[2] = {ADC_CHANNEL_0, ADC_CHANNEL_1};
    adc_init(channels, 2);

    printf("ADC Multi-Channel Sampling Example\r\n");

    while (1)
    {
        uint16_t adc0 = adc_read_channel(ADC_CHANNEL_0);
        uint16_t adc1 = adc_read_channel(ADC_CHANNEL_1);

        uint16_t volt0 = adc_read_voltage(ADC_CHANNEL_0);
        uint16_t volt1 = adc_read_voltage(ADC_CHANNEL_1);

        printf("ADC0: %u (%.2fV), ADC1: %u (%.2fV)\r\n",
               adc0, volt0 / 1000.0f, adc1, volt1 / 1000.0f);

        HAL_Delay(1000);
    }
}

void SystemClock_Config(void)
{
    /* 同上 */
}
